<?php

namespace App\Jobs;

use App\Model\BookSearch;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class SaveBookSearch implements ShouldQueue
{
    use InteractsWithQueue, Queueable, SerializesModels;

    public $openId;

    public $keyword;

    /**
     * SaveBookSearch constructor.
     * @param $openId
     * @param $keyword
     */
    public function __construct($openId, $keyword)
    {
        $this->openId = $openId;

        $this->keyword = $keyword;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        BookSearch::create([
            'open_id' => $this->openId,
            'keyword' => $this->keyword
        ]);
    }
}
